package cn.zjh.user.service.service.impl;

import cn.zjh.base.mapper.BaseMapper;
import cn.zjh.base.query.BaseQuery;
import cn.zjh.user.service.service.IBaseService;
import cn.zjh.base.utils.PageList;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;

public class BaseServiceImpl<T> implements IBaseService<T> {
    @Autowired
    private BaseMapper<T> baseMapper;

    @Override
    public List<T> loadAll() {
        return baseMapper.loadAll();
    }

    @Override
    public T loadById(Long id) {
        return baseMapper.loadById(id);
    }

    @Override
    public void remove(Long id) {
        baseMapper.remove(id);
    }

    @Override
    public void save(T t) {
        baseMapper.save(t);
    }

    @Override
    public void update(T t) {
        baseMapper.update(t);
    }

    @Override
    public PageList<T> queryData(BaseQuery baseQuery) {

        List<T> rows = baseMapper.queryData(baseQuery);

        Integer total = baseMapper.queryCount(baseQuery);

        return new PageList<T>(total,rows);
    }

    @Override
    public void batchDel(Long[] ids) {
        baseMapper.batchDel(ids);
    }
}
